/**
 * 
 */

 fn largest_str<'a>(str1: &'a str, str2: &'a str) -> &'a str {
     if str1.len() > str2.len() {
        str1
     } else {
        str2
     }
 }

 fn largest_str1<'a:'c,'b:'c,'c>(str1: &'a str, str2: &'b str) -> &'c str {
   if str1.len() > str2.len() {
      str1
   } else {
      str2
   }
}

 fn main() {
    let s1="good";
    let s2="bad";
    let result=largest_str(s1, s2);
    println!("{}和{}种较长的一个是{}", s1,s2,result);        

    let string1 = String::from("long string is long");
    let result;
    {
        let string2 = String::from("xyz");        
        result = largest_str(string1.as_str(), string2.as_str());
        println!("The longest string is {result}");
    }
    //这一句必须注释，否则会报告异常: borrowed value does not live long enough
    //而这依据提示是针对 result = largest_str(string1.as_str(), string2.as_str());
    //println!("The longest string is {result}");
    let haha=largest_str1(s1, s2);
    println!("The longest string is {haha}");
 }

